﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace TestTool
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }
        private void Form2_Load(object sender, EventArgs e)
        {
            this.txtusername.Text = Common.GetConfig("UserName");
            this.txtuserpwd.Text = Common.GetConfig("UserPwd");
            this.txtaccount.Text = Common.GetConfig("Account");
            this.txtkey.Text = Common.GetConfig("Key");

        }
        private void button1_Click(object sender, EventArgs e)
        {
            if (Common.saveSystem(this.txtusername.Text, this.txtuserpwd.Text, this.txtaccount.Text, this.txtkey.Text))
            {
                WeiXin wx = new WeiXin();
                long timestamp = Common.GetTimestamp();
                string json = wx.HttpGet(Common.GetConfig("Domain") + "?act=Login&sign=" + Common.MakeSign("Login", timestamp) + "&username=" + this.txtusername.Text + "&mobile=" + this.txtusername.Text + "&userpwd=" + this.txtuserpwd.Text + "&timestamp=" + timestamp, "");
                dynamic obj = wx.ConvertJson(json);
                if (obj.state)
                {
                    Common.saveUserToken(obj.data.Token);
                    this.Close();
                }
                MessageBox.Show(obj.msg);
                
            }
            else
            {
                MessageBox.Show("保存失败");
            }
        }

        
    }
}
